package com.neusoft.elmboot.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.neusoft.elmboot.po.User;

@Mapper
public interface UserMapper {
	
//login
 @Select("select * from user where userId=#{userId} and password=#{password}")
 public User getUserByIdByPass(User user);
 
 //check whether userId has already been in database when signing up
 //expected return values:0(no userId);1(already has userId)
 @Select("select count(*) from user where userId=#{userId}")
 public int getUserById(String userId);
 
 //create a new user in database
 @Insert("insert into user values(#{userId},#{password},#{userName},#{userSex},null,1)")
 public int saveUser(User user);
 
 //---------------------
 //return a user by userId
 @Select("select * from user where userId=#{userId}")
 public User getUser(String userId);
 
}